package Dao;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import Entity.User;

public class LoginDaoHelper {

	public User getUser(String username) throws IOException,
			ClassNotFoundException, SQLException {		
		String sql = "SELECT EmpNumber, Password,Roles FROM Employee WHERE EmpNumber=?";
		Connection con = DaoUtil.getConnection();
		PreparedStatement stm = con.prepareStatement(sql);
		stm.setString(1, username);
		ResultSet rs = stm.executeQuery();
		User user = new User("", "");
		while (rs.next()) {
			user.setUsername(rs.getString("EmpNumber"));
			user.setPassword(rs.getString("Password"));
			user.setRoles(rs.getString("Roles"));
		}
		return user;
	}
}